<template>
    <div class="operate">
        <template>
            <div class="operate-btn" :style="{ 'justify-content': tabPaneType == 'File' ? 'space-between' : 'flex-end' }">
                <div class="leftBtn" v-if="tabPaneType == 'File'">
                    <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleEntry('add')">新增条目</el-button>
                    <el-button size="mini" @click="handleCopyEntry('复制条目')">复制条目</el-button>
                    <el-button size="mini" @click="openRelevancyDialog('添加关联')" :disabled="!indexClauseList.length">添加关联</el-button>
                    <!-- <el-button size="mini" @click="openRelevancyDialog('添加关联')">添加关联</el-button> -->
                    <el-button size="mini" @click="delClauseDialog(itemCodes, '批量解除')">解除关联</el-button>
                </div>
                <div class="rightBtn">
                    <el-input
                        v-model="indexClauseRelationParam.entryNameOrCodeLike"
                        size="mini"
                        prefix-icon="el-icon-search"
                        placeholder="输入规则序号,编号或名称"
                        style="width: 230px; margin-right: 10px"
                        @input="clauseTextLikeQuery"
                        v-if="tabPaneType == 'File'"
                    />
                    <el-input
                        v-model="indexClauseRelationParamProduct.entryNameOrCodeLike"
                        size="mini"
                        prefix-icon="el-icon-search"
                        placeholder="输入规则序号,编号或名称"
                        style="width: 230px; margin-right: 10px"
                        @input="clauseTextLikeQuery"
                        v-if="tabPaneType == 'Product'"
                    />
                    <el-button size="mini" @click="clickRuleQuery">高级查询</el-button>
                    <el-button size="mini" @click="getIndexClauseRelationList(indexClauseRelationParam)">刷新</el-button>
                    <el-button size="mini" @click="downLoadGroupFileBtn">导出</el-button>
                    <el-button size="mini" @click="layoutDialog = true">布局设置</el-button>
                </div>
            </div>
            <div style="width: 98%; height: calc(100% - 58px); margin: 0 auto" v-if="tabPaneType == 'File'">
                <vxe-table
                    ref="upstreamTable"
                    :key="tableKey"
                    :data="indexClauseRelationList"
                    border
                    size="mini"
                    height="100%"
                    header-align="center"
                    show-overflow
                    resizable
                    auto-resize
                    @filter-change="filterChangeEvent"
                    @checkbox-change="clauseChangeEvent"
                    @checkbox-all="clauseChangeEvent"
                >
                    <vxe-column type="checkbox" width="50" fixed="left" align="center"></vxe-column>
                    <vxe-column
                        v-for="item in showFieldList"
                        :key="item.clauseNo"
                        :field="item.id"
                        :title="item.content"
                        :sortable="item.sortable"
                        :min-width="item.minWidth"
                        :filters="item.filters"
                        :filter-method="filterHandler"
                    >
                        <template slot-scope="scope">
                            <!-- <span v-if="['modifyTime'].includes(item.id)">{{timeFormat(scope.row.modifyTime) || '--'}}</span> -->
                            <span v-if="['thresholdValue1', 'thresholdValue2', 'thresholdValue3'].includes(item.id)">
                                {{ scope.row[item.id] ? thresholdTypeFormat(scope.row[item.id], scope.row.unit) : '--' }}
                            </span>
                            <span v-else-if="item.id === 'entryName'" @click="handleRowClick(scope.row)" class="text-hover">
                                {{ scope.row[item.id] }}
                            </span>
                            <!-- <span v-else-if="['accountControlValue'].includes(item.id)">
                                {{ setAccountControlValue(scope.row[item.id], scope.row) }}
                            </span> -->
                            <span v-else v-html="getTablesData(scope.row, item.id)"></span>
                        </template>
                    </vxe-column>
                    <vxe-column title="操作" width="200" fixed="right" align="center">
                        <template slot-scope="scope">
                            <a href="javascript:;" @click="handleEntry('look', scope.row)">查看</a>
                            <a href="javascript:;" @click="handleEntry('edit', scope.row)">修改</a>
                            <a href="javascript:;" @click="delClauseDialog(scope.row, '单个解除')">解除关联</a>
                        </template>
                    </vxe-column>
                </vxe-table>
            </div>
            <div style="width: 98%; height: calc(100% - 58px); margin: 0 auto" v-if="tabPaneType == 'Product'">
                <vxe-table
                    ref="upstreamTable"
                    :key="tableKey"
                    :data="indexClauseRelationListProduct"
                    border
                    size="mini"
                    height="100%"
                    header-align="center"
                    show-overflow
                    @filter-change="filterChangeEvent"
                    @checkbox-change="clauseChangeEventProduct"
                    @checkbox-all="clauseChangeEventProduct"
                >
                    <vxe-column type="checkbox" width="50" fixed="left" align="center"></vxe-column>
                    <vxe-column
                        v-for="item in showFieldList"
                        :key="item.clauseNo"
                        :field="item.id"
                        :title="item.content"
                        :sortable="item.sortable"
                        :min-width="item.minWidth"
                        :filters="item.filters"
                        :filter-method="filterHandler"
                    >
                        <template slot-scope="scope">
                            <!-- <span v-if="['modifyTime'].includes(item.id)">{{timeFormat(scope.row.modifyTime) || '--'}}</span> -->
                            <span v-if="['thresholdValue1', 'thresholdValue2', 'thresholdValue3'].includes(item.id)">
                                {{ scope.row[item.id] ? thresholdTypeFormat(scope.row[item.id], scope.row.unit) : '--' }}
                            </span>

                            <span v-else-if="item.id === 'entryName'" @click="handleRowClick(scope.row)" class="text-hover">
                                {{ scope.row[item.id] }}
                            </span>
                            <!-- <span v-else-if="['accountControlValue'].includes(item.id)">
                                {{ setAccountControlValue(scope.row[item.id], scope.row) }}
                            </span> -->
                            <span v-else v-html="getTablesData(scope.row, item.id)"></span>
                        </template>
                    </vxe-column>
                </vxe-table>
            </div>
        </template>
        <template>
            <!-- 复制条目 -->
            <CopyEntryDialog
                :treeNodeData="treeNodeData"
                :copyEntryDialog="copyEntryDialog"
                :indexClauseRelation="indexClauseRelation"
                :clauseCodesList="clauseCodesList"
                :relaCopy="relaCopy"
                :indexClauseRelationList="indexClauseRelationList"
                :Type="Type"
                @handleOneCopy="handleOneCopy"
                @emitCopyEntryDialog="emitCopyEntryDialog"
            ></CopyEntryDialog>
            <!-- 规则高级查询 -->
            <RuleQueryDialog
                :tabPaneType="tabPaneType"
                :ruleQueryDialog="ruleQueryDialog"
                @emitRuleQuery="emitRuleQuery"
                @emitConfirmQuery="emitConfirmQuery"
                @emitConfirmQueryProduct="emitConfirmQueryProduct"
            ></RuleQueryDialog>
            <!-- 解除关联确认窗口 -->
            <DeletionConfirmationDialog
                :delConfirmationDialog="delConfirmationDialog"
                @emitDialogVisible="emitDialogVisible"
                @emitHandleBtn="emitHandleBtn"
            >
                <div slot="content1">{{ delContent }}</div>
            </DeletionConfirmationDialog>
            <RiskTableLayout
                title="页面布局"
                :visible.sync="layoutDialog"
                :field-list="tableColumns"
                :selected-field-list="selectedFieldList"
                :fixed-field-list="fixedFieldList"
                table-name="COMPLIANCE_RULES1"
                @on-submit="onSubmit"
            />
        </template>
    </div>
</template>
<script lang="ts">
import { Component, Vue, Watch, Prop } from 'vue-property-decorator';
import RiskIconButton from '@/common/components/risk-icon-button.vue';
import CopyEntryDialog from './components/copy-entry-dialog.vue';
import RuleQueryDialog from './components/rule-query-dialog.vue';
import RiskTableLayout from '@/common/components/risk-table-layout.vue';
import DeletionConfirmationDialog from './commom/deletion-confirmation-dialog.vue';
import { timeFormat, numberFormat, unitShow } from '@/utils/tools';
import { downLoadFile } from '@/utils/request';
import { getTableLayout } from '@/common/api/commonApi';
import DictionConstUtil, { SGU_CACHE } from '@/utils/diction-const-util';
import Invest from '@/common/dict/invest';
@Component({
    name: 'ComplianceRules',
    components: {
        RiskIconButton,
        CopyEntryDialog,
        RuleQueryDialog,
        RiskTableLayout,
        DeletionConfirmationDialog,
    },
})
export default class ComplianceRules extends Vue {
    Invest: any = new Invest();
    timeFormat = timeFormat;
    @Prop() indexClauseRelation; // 当前点击的条款
    @Prop() indexClauseRelationProduct; // 当前点击的条款
    @Prop() clauseCodesList; // 条款多选全部数据
    @Prop() treeNodeData;
    @Prop() indexClauseList; // 条款列表数据
    @Prop() checkItemIs; // 检查是否勾选条款有未复核
    @Prop() tabPaneType; // 文件、产品
    // @Prop() indexClauseRelationList; // table数据
    copyEntryDialog: boolean = false;
    ruleQueryDialog: boolean = false;
    delConfirmationDialog: boolean = false;
    itemSettingDialog: boolean = false;
    timeout = null; // 防抖
    itemCodes = []; // 多选
    itemCodesProduct = []; // 多选--产品
    indexClauseRelationParam = {
        clauseCode: '',
        entryNameOrCodeLike: '',
    };
    indexClauseRelationParamProduct = {
        clauseCode: '',
        entryNameOrCodeLike: '',
    };
    delType = {
        type: '',
        content: '',
    }; // 解除关联类型
    indexClauseRelationList = [];
    indexClauseRelationListProduct = [];
    delContent: string = '是否解除当前关联关系？';
    layoutDialog: boolean = false; // 布局显示值
    showFieldList: any[] = []; // 要显示的表格列
    // 已选择字段列表
    selectedFieldList: any[] = [];
    fixedFieldList: any[] = [{ content: '规则编号', id: 'entryCode', sortable: true, minWidth: 100 }];
    iconDom: any = null;
    tableKey: number = 0;
    calcLoading: boolean = false;
    entryTypeArr: any[] = []; // 风险类型
    itemData = {
        type: '',
        title: '',
        name: '',
        content: '',
    };
    FundInfoList = [];
    FundGroupList = [];
    // 全部表格列
    tableColumns: any[] = [
        { content: '规则编号', id: 'entryCode', sortable: true, minWidth: 100 },
        { content: '规则说明', id: 'entryName', sortable: false, minWidth: 300 },
        { content: '变动序号', id: 'changeNo', sortable: false, minWidth: 80 },
        { content: '规则类型', id: 'entryTypes', sortable: false, minWidth: 100 },
        { content: '生效日期', id: 'beginDate', sortable: false, minWidth: 100 },
        { content: '失效日期', id: 'endDate', sortable: false, minWidth: 100 },
        { content: '优先级', id: 'level', sortable: false, minWidth: 80 },
        { content: '状态', id: 'entryStatusValid', sortable: false, minWidth: 100 },
        { content: '条款来源', id: 'controlGrade', sortable: false, minWidth: 100 },
        // { content: '条款来源', id: 'sourceType', sortable: false },
        { content: '作用范围', id: 'riskCalTypes', sortable: false, minWidth: 120 },
        { content: '阈值类型1', id: 'thresholdType1', sortable: false, minWidth: 100 },
        { content: '阈值1', id: 'thresholdValue1', sortable: false, minWidth: 100 },
        { content: '阈值类型2', id: 'thresholdType2', sortable: false, minWidth: 100 },
        { content: '阈值2', id: 'thresholdValue2', sortable: false, minWidth: 100 },
        { content: '阈值类型3', id: 'thresholdType3', sortable: false, minWidth: 100 },
        { content: '阈值3', id: 'thresholdValue3', sortable: false, minWidth: 100 },
        { content: '比较方向', id: 'compareType', sortable: false, minWidth: 100 },
        { content: '账户层次', id: 'originalAccountId', sortable: false, minWidth: 100 },
        { content: '控制类型', id: 'accountControlType', sortable: false, minWidth: 100 },
        { content: '控制账户', id: 'accountControlValue', sortable: false, minWidth: 120 },
        { content: '排除账户', id: 'accountDebarValue', sortable: false, minWidth: 120 },
        { content: '排除组', id: 'accountGroupDebarValue', sortable: false, minWidth: 120 },
        { content: '修改日期', id: 'modifyDate', sortable: false, minWidth: 100 },
        { content: '修改时间', id: 'modifyTime', sortable: false, minWidth: 100 },
        { content: '修改人', id: 'modifyUser', sortable: false, minWidth: 100 },
        { content: '规则来源', id: 'sourceType', sortable: false, minWidth: 100 },
        { content: '自定义分类', id: 'customType', sortable: false, minWidth: 100 },
    ];

    customTypesList: any[] = [];
    cutomTypes: any = null;
    fundGroups: any[] = [];
    funds: any[] = [];
    fundPojo: any = {};
    fundGroupPojo: any = {};
    Type = ''; // 关联条目-复制条目

    created() {
        this.indexClauseRelationList = [];
        this.getFoundInfo();
        this.getFoundGroup();
    }
    async mounted() {
        let fundPojo = {};
        let fundGroupPojo = {};

        // 条目组
        this.funds = (await DictionConstUtil.FNFundInfo()) || [];
        // 产品组信息
        this.fundGroups = (await DictionConstUtil.FNFundGroup()) || [];
        // 产品信息
        let funds = this.funds;
        // 产品组信息
        let fundGroups = this.fundGroups;
        funds.forEach(item => {
            fundPojo[item.fundCode] = item.fundNameSt;
        });
        fundGroups.forEach(item => {
            fundGroupPojo[item.fundGroupCode] = item.fundGroupName;
        });
        // -1 也在展示范围内
        fundPojo['-1'] = '全部选择';
        fundGroupPojo['-1'] = '全部选择';

        this.fundPojo = fundPojo;
        this.fundGroupPojo = fundGroupPojo;
        // 自定义风险分类
        // 自定义风险
        this.customTypesList = (await DictionConstUtil.FNCustomType()) || [];
        this.cutomTypes = DictionConstUtil.ListToPojo(this.customTypesList || []) || {};

        this.entryTypeArr = this.objToArr(this.Invest.entryType);
        this.queryLayout();
    }
    getFoundInfo() {
        this.$axios.get('/fundInfo/list').then((res: any) => {
            this.FundInfoList = [];
            this.FundInfoList = res;
        });
    }
    getFoundGroup() {
        this.$axios.post('/fundGroup/list').then((res: any) => {
            this.FundGroupList = [];
            this.FundGroupList = res;
        });
    }
    setAccountControlValue(param, param2) {
        this.$nextTick(() => {
            let data = [];
            param.forEach(item => {
                if (item == '-1') {
                    data.push('全部选择');
                } else {
                    if (String(param2.originalAccountId) == '0') {
                        this.FundInfoList.forEach(item2 => {
                            if (item2.fundCode == item) {
                                data.push(item2.fundNameSt);
                            }
                        });
                    } else {
                        this.FundGroupList.forEach(item3 => {
                            if (item3.fundGroupCode == item) {
                                data.push(item3.fundGroupName);
                            }
                        });
                    }
                }
            });
            return data.join(',');
        });
    }
    openRelevancyDialog(param) {
        if (this.indexClauseRelation.clauseCode == '' || typeof this.indexClauseRelation.clauseCode != 'string') {
            this.yh_message_warn('请选择条款!');
            return;
        }
        this.Type = param;
        this.copyEntryDialog = true;
        this.relaCopy = false;
    }
    @Watch('indexClauseRelation.clauseCode', { immediate: true, deep: true })
    watchIndexClauseRelation(val) {
        if (this.tabPaneType === 'File') {
            this.indexClauseRelationParam.clauseCode = val;
            this.indexClauseRelationList = [];
            this.getIndexClauseRelationList(this.indexClauseRelationParam);
        }
    }
    @Watch('indexClauseRelationProduct.clauseCode', { immediate: true, deep: true })
    watchIndexClauseRelationProduct(val) {
        if (this.tabPaneType === 'Product') {
            this.indexClauseRelationParamProduct.clauseCode = val;
            this.indexClauseRelationListProduct = [];
            this.getIndexClauseRelationList(this.indexClauseRelationParamProduct);
        }
    }
    refreshTable() {
        if (this.tabPaneType == 'File') {
            this.getIndexClauseRelationList(this.indexClauseRelationParam);
        } else if (this.tabPaneType == 'Product') {
            this.getIndexClauseRelationList(this.indexClauseRelationParamProduct);
        }
    }
    // 关联列表查询
    getIndexClauseRelationList(data) {
        if (sessionStorage.getItem('jumpParam-clauseCode') || sessionStorage.getItem('jumpParam-defaultFundCode')) {
            // 说明是第一次进来 由于缺失树节点的其他字段(indexType) 这次请求忽略
            return;
        }

        if (this.tabPaneType == 'File') {
            this.itemCodes = [];
            this.$axios.post('/zhiguan/indexClause/queryClauseEntry', { ...data }).then((res: any) => {
                this.indexClauseRelationList = [];
                if (res.list) {
                    // res.list.forEach(item => this.indexClauseRelationList.push(item));
                    this.indexClauseRelationList = JSON.parse(JSON.stringify(res.list));
                }
                if (this.ruleQueryDialog == true) {
                    this.yh_message_success('查询成功!');
                }
                this.ruleQueryDialog = false;
            });
        } else if (this.tabPaneType == 'Product') {
            console.log('关联列表查询Product');
            this.itemCodesProduct = [];
            this.$axios.post('/zhiguan/indexClause/queryClauseEntry', { ...data }).then((res: any) => {
                this.indexClauseRelationListProduct = [];
                if (res.list) {
                    // res.list.forEach(item => this.indexClauseRelationListProduct.push(item));
                    this.indexClauseRelationListProduct = JSON.parse(JSON.stringify(res.list));
                }
                if (this.ruleQueryDialog == true) {
                    this.yh_message_success('查询成功!');
                }
                this.ruleQueryDialog = false;
            });
        }
    }
    // 条款原文模糊搜索
    clauseTextLikeQuery(param) {
        this.debounce(this.refreshTable, 500);
    }
    // 条目多选
    clauseChangeEvent(checked, row, rowIndex) {
        this.itemCodes = [];
        checked.selection.forEach(item => this.itemCodes.push(item));
    }
    clauseChangeEventProduct(checked, row, rowIndex) {
        this.itemCodesProduct = [];
        checked.selection.forEach(item => this.itemCodesProduct.push(item));
    }
    // 点击高级查询btn
    clickRuleQuery() {
        this.ruleQueryDialog = true;
    }
    // 导出
    downLoadGroupFileBtn() {
        if (this.indexClauseRelationList.length == 0 && this.tabPaneType == 'File') {
            this.yh_message_warn('当前数据为空!');
            return;
        }
        if (this.indexClauseRelationListProduct.length == 0 && this.tabPaneType == 'Product') {
            this.yh_message_warn('当前数据为空!');
            return;
        }
        if (this.tabPaneType == 'File') {
            if (this.itemCodes.length > 0) {
                let data = [];
                this.itemCodes.forEach(item => {
                    data.push(item.entryCode);
                });
                downLoadFile({
                    url: '/zhiguan/indexClause/entry/export',
                    method: 'post',
                    data: {
                        ...this.indexClauseRelationParam,
                        exportEntryCode: data,
                    },
                });
            } else if (this.itemCodes.length == 0) {
                downLoadFile({
                    url: '/zhiguan/indexClause/entry/export',
                    method: 'post',
                    data: {
                        ...this.indexClauseRelationParam,
                        exportEntryCode: [],
                    },
                });
            }
        } else if (this.tabPaneType == 'Product') {
            if (this.itemCodesProduct.length > 0) {
                let data = [];
                this.itemCodesProduct.forEach(item => {
                    data.push(item.entryCode);
                });
                downLoadFile({
                    url: '/zhiguan/indexClause/entry/export',
                    method: 'post',
                    data: {
                        ...this.indexClauseRelationParamProduct,
                        exportEntryCode: data,
                    },
                });
            } else if (this.itemCodesProduct.length == 0) {
                downLoadFile({
                    url: '/zhiguan/indexClause/entry/export',
                    method: 'post',
                    data: {
                        ...this.indexClauseRelationParamProduct,
                        exportEntryCode: [],
                    },
                });
            }
        }
    }
    delClauseDialog(clauseCodes, param2) {
        if (this.itemCodes.length == 0 && param2 == '批量解除') {
            this.yh_message_warn('选择条目不可为空！');
            return;
        }
        this.delConfirmationDialog = true;
        this.delType.type = param2;
        if (param2 == '单个解除') {
            this.delType.content = clauseCodes.entryCode;
        } else {
            this.delType.content = '';
        }
    }
    setItemDetailBtn(param1, param2) {
        if (param1 == 'add') {
            this.itemData = {
                type: param1,
                title: '新增条目',
                name: '新增条目',
                content: '',
            };
        } else if (param1 == 'edit') {
            this.itemData = {
                type: param1,
                title: '编辑：' + param2.entryCode,
                name: '编辑：' + param2.entryCode,
                content: param2.entryCode,
            };
        } else if (param1 == 'look') {
            this.itemData = {
                type: param1,
                title: '查看：' + param2.entryCode,
                name: '查看：' + param2.entryCode,
                content: param2.entryCode,
            };
        }
        this.itemSettingDialog = true;
    }
    // 关联条目
    emitCopyEntryDialog(param1, param2) {
        this.copyEntryDialog = param1;
        if (param2 == '确认关联') {
            this.getIndexClauseRelationList(this.indexClauseRelationParam);
            this.$emit('emitRefreshChild');
        }
    }
    // 解除关联
    handleRemoveRelations() {
        let data = [];
        let entryCodeS = [];
        if (this.delType.type == '批量解除') {
            this.itemCodes.forEach(item => {
                entryCodeS.push(item.entryCode);
            });
        } else if (this.delType.type == '单个解除') {
            entryCodeS = [this.delType.content];
        }
        this.$axios
            .post('/zhiguan/indexClause/deleteClauseEntry', {
                clauseCode: this.indexClauseRelation.clauseCode,
                entryCodeSS: entryCodeS,
            })
            .then((res: any) => {
                this.yh_message_success('解除关联成功！');
                this.delConfirmationDialog = false;
                this.getIndexClauseRelationList(this.indexClauseRelationParam);
            })
            .catch(() => {
                this.delConfirmationDialog = false;
            });
    }
    // 高级查询显示emit
    emitRuleQuery(param) {
        this.ruleQueryDialog = param;
    }
    // 高级查询确认
    emitConfirmQuery(param) {
        let data = param;
        data.clauseCode = this.indexClauseRelation.clauseCode;
        this.getIndexClauseRelationList(data);
    }
    // 高级查询确认 -- 产品
    emitConfirmQueryProduct(param) {
        console.log('899999');
        let data = param;
        data.clauseCode = this.indexClauseRelationProduct.clauseCode;
        this.getIndexClauseRelationList(data);
    }
    // 删除确认窗口显示
    emitDialogVisible(param) {
        this.delConfirmationDialog = param;
    }
    // 条目设置窗口
    emitItemSetting(param1, param2) {
        this.itemSettingDialog = param1;
    }
    // 删除确认窗口
    emitHandleBtn() {
        if (['批量解除', '单个解除'].includes(this.delType.type)) {
            this.handleRemoveRelations();
        }
    }
    // 防抖
    debounce(fun, time = 500) {
        if (this.timeout) {
            clearTimeout(this.timeout);
        }
        this.timeout = setTimeout(() => {
            fun();
        }, time);
    }
    filterChangeEvent() {}
    /**
     * 提交成功后回调
     * @param {Object} 回调数据
     */
    async onSubmit(data) {
        await this.queryLayout();
    }
    /* **************************** 布局设置start ***************************** */
    // 获取页面布局信息
    async queryLayout() {
        this.calcLoading = true;
        const resList: any = await new Promise((resolve, reject) => {
            getTableLayout('COMPLIANCE_RULES1')
                .then((res: any) => {
                    resolve(res);
                })
                .catch(err => {
                    reject(err);
                });
        });
        if (resList) {
            this.selectedFieldList = JSON.parse(resList);
            this.showFieldList = this.fixedFieldList.concat(this.selectedFieldList);
            this.calcLoading = false;
        } else {
            this.showFieldList = this.tableColumns;
            this.selectedFieldList = this.tableColumns;
            this.calcLoading = false;
        }
        // 重新渲染表格
        this.tableKey++;
        // this.changeTable();
    }
    changeTable() {
        const _this = this;
        this.$nextTick(() => {
            let iconDom = (_this.$refs['upstreamTable'] as any).$el.querySelectorAll('.vxe-icon--funnel');
            for (let i: any = 0; i < iconDom.length; i++) {
                if (['规则说明'].includes(iconDom[i].parentNode.parentNode.children[0].innerHTML)) {
                    iconDom[i].className = 'vxe-filter--btn el-icon-search';
                }
            }
        });
    }
    // 转表格筛选下拉框数据
    objToArr(param) {
        const list = [];
        for (const key in param) {
            list.push({ label: param[key], value: key });
        }
        return list;
    }
    // 处理table中的数据
    getTablesData(data: any, props: any) {
        // 自定义风险分类
        let datas = data[props];
        if (props == 'entryTypes') {
            datas = data['entryType'];
            return DictionConstUtil.EntryType[datas];
        } else if (props == 'entryStatusValid') {
            if (data[props] == true) {
                let span = '<span style="color:green">启用</span>';
                return span;
            } else {
                let span = '<span style="color:red">禁用</span>';
                return span;
            }
        } else if (props == 'sourceType') {
            return DictionConstUtil.SourceType[datas];
        } else if (props == 'beginDate') {
            if (datas == '0') {
                return '';
            } else {
                return datas;
            }
        } else if (props == 'endDate') {
            if (datas == '0') {
                return '';
            } else {
                return datas;
            }
        } else if (props == 'modifyTime') {
            return timeFormat(datas);
        } else if (props == 'originalAccountId') {
            return DictionConstUtil.OriginalAccountType[datas];
        } else if (props == 'accountControlValue') {
            if (datas && datas.length > 0) {
                if (String(data.originalAccountId) === '0') {
                    let fundNames = datas.map(item => this.fundPojo[item]);
                    return fundNames.join(',');
                } else {
                    let fundGroupNames = datas.map(item => this.fundGroupPojo[item]);
                    return fundGroupNames.join(',');
                }
            } else {
                return datas;
            }
        } else if (props == 'accountDebarValue') {
            if (datas && datas.length > 0) {
                let fundNames = datas.map(item => this.fundPojo[item]);
                return fundNames.join(',');
            } else {
                return datas;
            }
        } else if (props == 'accountGroupDebarValue') {
            if (datas && datas.length > 0) {
                if (String(data.originalAccountId) === '0') {
                    let fundNames = datas.map(item => this.fundPojo[item]);
                    return fundNames.join(',');
                } else {
                    let fundGroupNames = datas.map(item => this.fundGroupPojo[item]);
                    return fundGroupNames.join(',');
                }
            } else {
                return datas;
            }
        } else {
            return datas;
        }
    }
    // 表格列筛选数据
    filterHandler({ option, row, column }) {
        const property = column['property'];
        return row[property].includes(option.data);
    }
    thresholdTypeFormat(value, unit): string {
        // 三目运算符, unit为'%'和'万元'、'万股'的由后端处理了，不由numberFormat方法处理
        return ['%', '万元', '万股'].includes(unit) ? value : numberFormat(value.replace(/[^0-9.]/gi, ''), unit) + unitShow(unit);
    }
    handleRowClick(row) {
        const msg = {
            type: 'look-entry-details',
            path: `/lookEntryDetails?entryCode=${row.entryCode}`,
            title: `条目详情-${row.entryCode}`,
        };
        top.window.postMessage(msg, '*');
    }

    relaCopy: boolean = false;

    handleCopyEntry(param) {
        if (!this.indexClauseRelation.clauseCode) {
            this.yh_message_warn('请先选中操作的条款!');
            return;
        }
        this.Type = param;
        this.copyEntryDialog = true;
        this.relaCopy = true;

        // if (this.itemCodes.length === 1) {
        //     this.handleEntry('copy', { entryCode: this.itemCodes[0].entryCode });
        // } else {
        //     this.copyEntryDialog = true;
        //     this.relaCopy = true;
        // }
    }

    /**
     * 单条复制事件
     */
    handleOneCopy(entryCode): void {
        this.handleEntry('copy', { entryCode });
    }

    handleEntry(type, row?): void {
        if (!this.indexClauseRelation.clauseCode) {
            this.yh_message_warn('请先选中操作的条款!');
            return;
        }

        let clauseData = this.tabPaneType === 'File' ? this.indexClauseRelation : this.indexClauseRelationProduct;
        let msg = {
            type: 'item-control-dialog',
            title: '条目设置dialog',
            method: type,
            entryData: { entryCode: row?.entryCode || '' },
            clauseData: clauseData,
        };

        top.window.postMessage(msg, '*');
    }
}
</script>
<style lang="scss" scoped>
.operate {
    margin-top: 15px;
    .operate-btn {
        // border: 1px solid green;
        width: 98%;
        display: flex;
        margin: 10px auto;
    }
}

.text-hover {
    cursor: pointer;

    &:hover {
        color: #518bd3;
        text-decoration: #518bd3 solid underline;
    }
}

a {
    color: #578bec;
    padding: 0 5px;
}
</style>
